Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add lapack/base/dlas2 #2833

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

Pranavchiku
Copy link
Member

Towards #2464.

Description

What is the purpose of this pull request?

This pull request adds JS implementation for lapack/base/dlas2.

Related Issues

Does this pull request have any related issues?

NA

Questions

Any questions for reviewers of this pull request?

No.

Other

Any other information relevant to this pull request? This may include screenshots, references, and/or implementation notes.

No.

Checklist

Please ensure the following tasks are completed before submitting this pull request.


@stdlib-js/reviewers

@Pranavchiku Pranavchiku added Feature Issue or pull request for adding a new feature. Base Issue or pull requests related to "low-level" functionality oriented toward library consumers. JavaScript Issue involves or relates to JavaScript. LAPACK Issue or pull request related to the Linear Algebra Package (LAPACK). labels Aug 26, 2024
Comment on lines +120 to +122
var out = new Float64Array( 2 );
dlas2( 1.0, 2.0, 3.0, out );
console.log( out );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pranavchiku You need to go beyond just copy-pasting a prior example. This applies to all your PRs.

Comment on lines +41 to +44
A = ( randu() * 100.0 ) - 50.0;
B = ( randu() * 100.0 ) - 50.0;
C = ( randu() * 100.0 ) - 50.0;
out = new Float64Array( 2 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you doing this within the b.tic()? This benchmark needs to be refactored. It is also not clear why were are reusing out values in subsequent iterations.

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = dlas2( A, B, C, out, 1, 0 );
A = out[ i%out.length ];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.

if ( fhmx === 0.0 ) {
ssmax = ga;
} else {
ssmax = max( fhmx, ga ) * sqrt( 1.0 + pow( min( fhmx, ga ) / max( fhmx, ga ), 2 ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For squaring numbers, use abs2. It is a much lighter weight dependency and will be faster in general.

} else {
as = 1.0 + ( fhmn / fhmx );
at = ( fhmx - fhmn ) / fhmx;
c = 1.0 / ( sqrt( 1.0 + pow( as * au, 2 ) ) + sqrt( 1.0 + pow( at * au, 2 ) ) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment.


out = new Float64Array( 2 );
out = dlas2( 2.0, 3.0, 4.0, out );
expected = new Float64Array( [ 1.5513263285176897, 5.1568776039816795 ] );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pranavchiku How did you compute these expected values? R, Mathematica, something else? It would be good to include a comment here (as we do in other parts of the codebase) specifying how expected values were computed.

t.end();
});

tape( 'the function computes the eigenvalues of a 2x2 symmetric matrix', function test( t ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you are computing singular values, not eigenvalues values. Applies here and elsewhere.

t.end();
});

tape( 'the function supports complex access pattern to store computed values', function test( t ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Pranavchiku You need to include the tests from test.dlas2.js here. Don't take shortcuts. It is not a given that the underlying implementation is the same for the main and ndarray exports. Always test to the interface, NOT the implementation.

t.end();
});

tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) {
tape( 'the function supports a negative `out` stride', function test( t ) {

Follow the conventions found elsewhere for test descriptions.

t.end();
});

tape( 'the function supports complex access pattern to store computed values', function test( t ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having such a test is fine ("complex access patterns"), but you also should have tests for specific behavior. E.g., "the function supports an out stride", "the function supports supports an out offset", etc, where you hold everything constant except for the behavior you want to test. Tests should build on one another.

@kgryte kgryte added the Needs Changes Pull request which needs changes before being merged. label Sep 17, 2024
@kgryte kgryte mentioned this pull request Sep 17, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Base Issue or pull requests related to "low-level" functionality oriented toward library consumers. Feature Issue or pull request for adding a new feature. JavaScript Issue involves or relates to JavaScript. LAPACK Issue or pull request related to the Linear Algebra Package (LAPACK). Needs Changes Pull request which needs changes before being merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants